package com.da.javatest.niuke.jianzhi;

import com.da.javatest.niuke.common.ListNode;

/**
 * @author chenlida
 * @date 2020/10/22 19:14
 * https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C36Solution {
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        while (pHead1 != null) {
            ListNode p2 = pHead2;
            while (p2 != null) {
                if (pHead1 == p2) {
                    return pHead1;
                }
                p2 = p2.next;
            }
            pHead1 = pHead1.next;
        }
        return null;
    }
}
